def custom_slice(string, start, end):
    result = ""
    for i in range(len(string)):
        if start <= i < end:
            result += string[i]
    return result

# 示例字符串
string = "Hello, World!"

# 自定义切片
start = 7
end = 12
custom_result = custom_slice(string, start, end)
print(f"自定义切片结果: {custom_result}")

# Python自带切片
python_result = string[start:end]
print(f"Python自带切片结果: {python_result}")